package com.bookkeeping.cn.util;


import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bookkeeping.cn.R;

public class LoadingUtils {
    private static View loadingView;
    private static ViewGroup rootView;

    public static void showLoading(Activity activity) {
        if (loadingView == null) {
            rootView = activity.findViewById(android.R.id.content);
            loadingView = LayoutInflater.from(activity).inflate(R.layout.layout_loading, rootView, false);
        }

        if (loadingView.getParent() == null) {
            rootView.addView(loadingView);
        }
    }

    public static void hideLoading() {
        if (loadingView != null && loadingView.getParent() != null) {
            rootView.removeView(loadingView);
        }
    }
}